---
# collectd client setup 

# install pkg
- name: install collectd
  yum: name=collectd state=installed

# enable collectd
- name: enable collectd svc
  service: state=running enabled=true name=collectd

# install collected.conf
- name: /etc/collectd.conf
  template: src=collectd.conf.j2 dest=/etc/collectd.conf
  notify:
  - restart collectd

# install collectd-network config
- name: /etc/collectd.d/network.conf
  copy: src=network-client.conf dest=/etc/collectd.d/network.conf
  notify:
  - restart collectd
  when: not inventory_hostname.startswith('log')

# install collectd-network config
- name: /etc/collectd.d/network.conf
  copy: src=network-server.conf dest=/etc/collectd.d/network.conf
  notify:
  - restart collectd
  when: inventory_hostname.startswith('log')

# apache - localhost only - pretty much any apache server
- name: install collectd-apache
  yum: state=installed name=collectd-apache
  notify:
  - restart collectd
  when: collectd_apache is defined

- name: /etc/collectd/apache.conf
  copy: src=apache.conf dest=/etc/collectd.d/apache.conf
  notify:
  - restart collectd
  when: collectd_apache is defined


# Three tasks for handling our custom selinux module
- name: ensure a directory exists for our custom selinux module
  file: dest=/usr/share/collectd state=directory

- name: copy over our custom selinux module
  copy: src=selinux/fi-collectd.pp dest=/usr/share/collectd/fi-collectd.pp
  register: selinux_module

- name: install our custom selinux module
  command: semodule -i /usr/share/collectd/fi-collectd.pp
  when: selinux_module|changed


  
# each of the below should move to a separate task list
# since they are odd-balls and one-offs

# bind - localhost only - ns servers only

# fedmsg - busgateway## only
  # add /usr/share/collectd/fedmsg-types.db
  
# memcached - memcached only

# postgres - this is a conn check
## add /usr/share/collectd/pgconn-types.db 

# openvpn - for bastion/openvpn gateways only

# mysql
## collectd-mysql

# haproxy
## add /usr/share/collectd/haproxy-types.db
## add socat pkg
## 

# webproxy

  
